﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Spring.Context;
using Spring.Context.Support;
using Microsoft.Practices.Unity;
using System.Collections;
using System.Windows.Controls.Primitives;
using Microsoft.Windows.Controls.Ribbon;
using Infrastructure.WpfClient.Constants;



using Skynet.Administracion.Views.ExamCategoryMgm;
using Microsoft.Practices.Composite.Events;
namespace Skynet.Shell
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>        
    public partial class MainWindow : Window
    {
        [Dependency]
        public Infrastructure.WpfClient.Services.Navigation.INavigationService NavigationService{ get; set; }


        [Dependency]
        public IUnityContainer Container { get; set; }

        public MainWindow()
        {            
            InitializeComponent();
            
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("test");
        }

        private void C2SPerformance(object sender, RoutedEventArgs e)
        {
            
        }

        private void T3Performance(object sender, RoutedEventArgs e)
        {
            var full = (GC.GetTotalMemory(false)/1024/1024);
            MessageBox.Show(full.ToString());
            GC.Collect();
            var fulls = (GC.GetTotalMemory(true) / 1024 / 1024);
            MessageBox.Show(fulls.ToString());

            //this.NavigationService.Navigate<C2SModule.Views.Performance.IPerformanceView>("LayoutWorkspace");
        }


        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
        //    this.MenuTitle.Header = Properties.Resources.MainTitle; 
            this.miLogin.Header = Properties.Resources.LoginTitle; 
            

        }

        private void Authors_Click(object sender, RoutedEventArgs e)
        {
            
            
        }

        private void btnAddAuthor_Click(object sender, RoutedEventArgs e)
        {
            
            
        }

        private void btnmultiTouch_Click(object sender, RoutedEventArgs e)
        {
            
            //this.NavigationService.Navigate<Skynet.WPF4.Views.MultiTouch.IMultiTouchView>(Infrastructure.WpfClient.Constants.RegionNames.SingleActiveRegion);
        }

        private void btnnewControls_Click(object sender, RoutedEventArgs e)
        {
            //this.NavigationService.Navigate<Skynet.WPF4.Views.NewControls.INewControlsView>(Infrastructure.WpfClient.Constants.RegionNames.SingleActiveRegion);
        }

        private void NTAddAuthor_Click(object sender, RoutedEventArgs e)
        {
         
        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void btnAuthorsDS_Click(object sender, RoutedEventArgs e)
        {
         //   this.NavigationService.Navigate<Skynet.C2SModule.Views.AuthorsDSMgmt.IAuthorView>(Infrastructure.WpfClient.Constants.RegionNames.BodySingleWorkspace);
        }

        private void btnUnmanagment_Click(object sender, RoutedEventArgs e)
        {
            var rep = new BusinessLogic.ResourceAccess.WinApiAccess.SkynetWinLibrary();
            var res = rep.sum(5, 6);
            MessageBox.Show(res.ToString()); 
        }

   
        private void BodySingleWorkspace_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {            
            if ((bool)e.NewValue == true)
            {
                this.frameWorkspace.Visibility = System.Windows.Visibility.Collapsed;
                this.TabWorkspace.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        private void frameWorkspace_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {            
            if ((bool)e.NewValue == true)
            {
                this.BodySingleWorkspace.Visibility = System.Windows.Visibility.Collapsed;
                this.TabWorkspace.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        private void TabWorkspace_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue == true)
            {
                this.BodySingleWorkspace.Visibility = System.Windows.Visibility.Collapsed;
                this.frameWorkspace.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        private void btnSingle_Click(object sender, RoutedEventArgs e)
        {
          //  this.NavigationService.Navigate<C2SModule.Views.CreateAuthor.ICreateAuthorView>(Infrastructure.WpfClient.Constants.RegionNames.BodySingleWorkspace);
            
        }

        private void btnTab_Click(object sender, RoutedEventArgs e)
        {
         ///   this.NavigationService.Navigate<C2SModule.Views.CreateAuthor.ICreateAuthorView>(Infrastructure.WpfClient.Constants.RegionNames.TabWorkspace);
        }

        private void btnFrame_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("http://www.bing.com",  UriKind.Absolute));
            
        }
        private void btnFrame2_Click(object sender, RoutedEventArgs e)
        {
         //   this.NavigationService.Navigate<C2SModule.Presenters.Animation.AnimationPresenter>(RegionNames.FrameWorkspace);

            this.NavigationService.Navigate(new Uri("pack://application:,,,/Skynet.C2SModule;component/Views/AuthorsDSMgmt/AuthorsViewMgmt.xaml", UriKind.Absolute));
        }

        private void btnobjcontext_Click(object sender, RoutedEventArgs e)
        {
            var ent = this.Container.Resolve<Skynet.BusinessEntities.SkyNetLibraryEntities>();            
            var ls = ent.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Unchanged);

        }

        private void btnCreatePublisher_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnReadBook_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnCreateBook_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnWriteBook_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnPrintBook_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnAzureMgm_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate<Infrastructure.WpfClient.Views.AzureMgm.IAzureMgmView>(Infrastructure.WpfClient.Constants.RegionNames.BodySingleWorkspace); 
        }

        private void mgmUsuarios_Click(object sender, RoutedEventArgs e)
        {
            //this.NavigationService.Navigate<ICustomerMgmView>(RegionNames.BodySingleWorkspace);
        }

        private void mgmCategoriasExamen_Click(object sender, RoutedEventArgs e)
        {


            var res = DateTime.Now.ToLongTimeString();
            this.NavigationService.Navigate<IExamCategoryMgmView>(RegionNames.FrameWorkspace);
        }

        private void mgmExamenes_Click(object sender, RoutedEventArgs e)
        {
            //this.NavigationService.Navigate<IExamMgmView>(RegionNames.BodySingleWorkspace);
        }

        private void btnFlowReader_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void btnLogOut_Click(object sender, RoutedEventArgs e)
        {
            var entradas = this.Container.Resolve<IEventAggregator>();
            entradas.GetEvent<Infrastructure.WpfClient.GlobalEvents.LogOutApplicationEvent>().Publish(null);
        }
    }    
}
